package me.leiusual.sharing.repository.model

import java.util.concurrent.atomic.AtomicBoolean

/**
 * author: leiusual
 * create on: 2019/1/4
 * description: 数据包装，添加已处理标记。
 */
abstract class DataWrapper<out T> {

  private val hasBeenHandled = AtomicBoolean(false)

  fun getIfNotHandled(): DataWrapper<T>? {
    return if (hasBeenHandled.compareAndSet(false, true)) this else null
  }
}